package com.bmps.springcloud.insuredmicroservice.service.underwrite.strategy.insurance;

import com.bmps.springcloud.insuredmicroservice.config.accept.ProductConfig;
import com.bmps.springcloud.insuredmicroservice.constant.accept.AcceptConstant;
import com.bmps.springcloud.insuredmicroservice.constant.accept.UnderWriteConstant;
import com.bmps.springcloud.insuredmicroservice.model.accept.resquest.AcceptRequestDataModel;
import com.bmps.springcloud.insuredmicroservice.model.accept.resquest.CustInfoModel;
import com.bmps.springcloud.insuredmicroservice.model.accept.resquest.InsurantModel;
import com.bmps.springcloud.insuredmicroservice.model.accept.resquest.ProductModel;
import com.bmps.springcloud.insuredmicroservice.model.underwrite.InsuredModel;
import com.bmps.springcloud.insuredmicroservice.repository.underwrite.coresystem.InsuredCoreRepository;
import com.bmps.springcloud.insuredmicroservice.util.accept.AcceptUtil;

/**
 *
 * @author Administrator
 * @date 2021/3/1517:17
 */
public class Net009InsuranceStrategy implements InsuranceStrategy {
    @Override
    public InsuredModel checkInsuredRolesByRiskCode(AcceptRequestDataModel acceptRequestDataModel, InsuredCoreRepository insuredCoreRepository, ProductModel productModel, ProductConfig productConfig) {
        CustInfoModel custInfoModel = acceptRequestDataModel.getRequest().getCustInfo();
        InsurantModel insurantModel = AcceptUtil.getInsurantModelBySeq(productModel.getProdInsSeq(), custInfoModel.getInsurants().getInsurant());
        if (!AcceptConstant.OCCUPATION_ONE_TO_SIX.contains(insurantModel.getOccupationType())) {
            //职业1-6类
            return AcceptUtil.getInsuredResponse(UnderWriteConstant.UNDER_WRITE_FIAL_CODE,
                    String.format(UnderWriteConstant.UNDER_WRITE_NPGG0016_MESSAGE, insurantModel.getOccupationType()));
        }
        if (!(productConfig.getRelationList().contains(insurantModel.getRelToApp()))) {
            return AcceptUtil.getInsuredResponse(UnderWriteConstant.UNDER_WRITE_FIAL_CODE,
                    UnderWriteConstant.UNDER_WRITE_NUGG0007_MESSAGE);
        }
        return AcceptUtil.getInsuredResponse(AcceptConstant.RESULT_SUCCESS_CODE, AcceptConstant.RESULT_SUCCESS_MESSAGE);
    }
}
